﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace MediaRecommender.Model
{
    //simple class that writes strings to a file, used to debug and write logs.
    static class WriteToLog
    {
        static private string dirPath = "\\P3Project log folder\\" ;
        static private string fullPath = dirPath + "log-" + Convert.ToString(DateTime.Now).Replace(":", ";").Replace("\\", "-").Replace("/", "-") + ".txt";
        static public void WriteLog (string input)
        {
              //C:\Users\Frederik\Desktop
            //Method to print out the text to a chatlog
            string[] lines = { input };
            if (Directory.Exists(dirPath))
            {
                System.IO.File.AppendAllLines(fullPath, lines);
            }
            else
            {
                Directory.CreateDirectory(dirPath);
                System.IO.File.AppendAllLines(fullPath, lines);
            }
        }

        static public void WriteLog(string input, string fileName)
        {
            //C:\Users\Frederik\Desktop
            //Method to print out the text to a chatlog
            string[] lines = { input };
            if (Directory.Exists(dirPath))
            {
                System.IO.File.AppendAllLines(dirPath + fileName, lines);
            }
            else
            {
                Directory.CreateDirectory(dirPath);
                System.IO.File.AppendAllLines(fullPath + fileName, lines);
            }
        }
    }
}
